package com.zbkj.admin.service.impl;

import cn.hutool.core.util.ObjUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.zbkj.admin.mapper1.EbDividendFlowingWaterMapper;
import com.zbkj.admin.pojo.EbDividendFlowingWaterEntity;
import com.zbkj.admin.service.EbDividendFlowingWaterService;
import lombok.RequiredArgsConstructor;
import net.dreamlu.mica.core.result.R;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
@RequiredArgsConstructor
public class EbDividendFlowingWaterServiceImpl extends ServiceImpl<EbDividendFlowingWaterMapper, EbDividendFlowingWaterEntity> implements EbDividendFlowingWaterService {

    /**
     * 分红审批记录
     *
     * @param page      分页数据
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @return 分页后数据
     */
    @Override
    public R<PageInfo<EbDividendFlowingWaterEntity>> page(Page<EbDividendFlowingWaterEntity> page, LocalDateTime startDate, LocalDateTime endDate) {
        PageInfo<EbDividendFlowingWaterEntity> objectPageInfo = PageHelper.startPage(page.getPageNum(), page.getPageSize()).doSelectPageInfo(() ->
                list(QueryWrapper.create()
                .from(EbDividendFlowingWaterEntity.class).gt(EbDividendFlowingWaterEntity::getCreatedTime, startDate, ObjUtil::isNotEmpty)
                .lt(EbDividendFlowingWaterEntity::getCreatedTime, endDate, ObjUtil::isNotEmpty)));
        return R.success(objectPageInfo);
    }

}
